#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++) 
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;

int read() {
	int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-', ch = getchar(); 
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); return f ? -x : x;
}

const int N = 5e5 + 10;

int n, x, a[N];
map < int, int > f;

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	for(int T = in; T; T--) {
		n = in; x = in;
		f.clear();
		rep(i, 1, n) a[i] = in, f[a[i]]++;
		int ans = 1, res = 0;
		if(x == 0) {
			rep(i, 1, n) ans = max(ans, f[a[i]]);
			cout << ans << " " << res << endl; continue;
		}
		rep(i, 1, n) {
			int t = f[a[i]] + f[a[i] ^ x];
			if(t > ans) {
				ans = t; res = f[a[i] ^ x];
			} else if(t == ans) res = min(res, f[a[i] ^ x]);
		}
		cout << ans << " " << res << endl;
	}
	return 0;
}
